// import jsonp from 'common/js/jsonp.js'
import axios from 'axios'

/* eslint-disable */
// 获取 物品详情页数据
export function getGoodsDetail (articleid) {
  const url = '/apizdm/pdetail?'+ 'articleid=' + articleid
  return axios.get(url, {
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}

export function evaluateGoods(articleId, channelId, rating ) {
  if (!articleId || !rating) return
  // https://zhiyou.m.smzdm.com/user/rating/jsonp_add
  let url = '/apizdm/evaluate'
  let callBack = '__jp' + String(Math.random()).slice(2,16)
  let mparams = Object.assign({}, {
    callback: callBack,
    channel_id: channelId || '3',
    article_id: articleId,
    rating: rating,
    client_type: 'WAP',
    event_key: '点值',
    otype: rating > 0 ? '点值' : '点不值',
    aid: 12139552,
    p: '无',
    cid: '3',
    source: '无',
    atp: '3',
    tagID: '无',
    sourcePage: 'https://m.smzdm.com/',
    sourceMode: '无',
    _: new Date().getTime()
  })
  return axios.get(url, {
    params: mparams
  }).then((res) => {
    return Promise.resolve(res.data)
  })
}
